<?php

namespace app\console\model;

use think\Model;
use app\console\model\MemberMessage as MemberMessageModel;

class Promotion extends Model
{
    // 模型事件
    protected static function init()
    {

        // 写入前
        self::event('before_write', function ($data) {
            $data->picUrl = uploadImg('picUrl', 'shop');                                                                //生成图片
            $data->create_time = strtotime($data->create_time);
        });

        // // 新增后
        // self::event('after_insert', function ($data) {
        //     $model = new MemberMessageModel();
        //     $model->save(['member_id' => '0', 'title' => $data->title, 'content' => $data->content, 'create_time' => time()]);
        // });
    }
}